var hyjyHtml = "";
var tzggHtml = ""
function initInfoArea(key, fun) {
	var url = context + '/app/Vinfo.do?method=infolistjason&key=' + key
			+ '&size=7';

	Ext.Ajax.request({
				// 请求地址
				url : url,
				scriptTag : true,
				// 成功时回调
				success : function(response, options) {
					var json = response.responseText;
					var o = Ext.util.JSON.decode(json);

					if (o.success) {
						if (o.totalCount > 0) {
							var list = o.infoList;
							fun(list);
						}
					} else {
						return '[]';
						Ext.Msg.alert('提示', '获取栏目信息失败');
					}
				}
			});

}

/**
 * 获取会议纪要数据
 */
function getHyjy(list) {
	for (var one in list) {

		for (var key in list[one])

		{
			if (key == "title") {

				hyjyHtml += "&nbsp;<p>· <a href='" + context
						+ "/app/Vinfo.do?method=viewinfo&id=" + list[one].id
						+ "' target='_blank' class='oaFont'>" + list[one].title
						+ "</a></p>&nbsp;";

			}

		}

	}

	Ext.getCmp("hyjy").body.update(hyjyHtml);
}

/**
 * 获取通知公告要数据
 */
function getTzgg(list) {
	for (var one in list) {

		for (var key in list[one])

		{
			if (key == "title") {

				tzggHtml += "&nbsp;<p>· <a href='" + context
						+ "/app/Vinfo.do?method=viewinfo&id=" + list[one].id
						+ "' target='_blank' class='oaFont'>" + list[one].title
						+ "</a></p>&nbsp;";

			}

		}

	}

	Ext.getCmp("tzgg").body.update(tzggHtml);

}

Ext.onReady(function() {

	// NOTE: This is an example showing simple state management. During
	// development,
	// it is generally best to disable state management as dynamically-generated
	// ids
	// can change across page loads, leading to unpredictable results. The
	// developer
	// should ensure that stable state ids are set for stateful components in
	// real apps.
	Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
	var tools = [{
				id : 'gear',
				handler : function() {
					Ext.Msg.alert('Message', 'The Settings tool was clicked.');
				}
			}, {
				id : 'close',
				handler : function(e, target, panel) {
					panel.ownerCt.remove(panel, true);
				}
			}];
			
	var scimgs = '';		
	
	var toolbar = '';
	
	if(roles.containsKey('admin')){
		toolbar += '<a href="'+context+'/system/console" target="_blank" tilte="系统控制台"><img src="'+context+'/extframe/images/tools.png"></a>';
	}

	var viewport = new Ext.Viewport({
		layout : 'border',
		items : [

		{
					region : 'east',
					width : 70, // give east and west regions a width
					minSize : 70,
					maxSize : 400,
					margins : '0 0 0 0',
					border : false,
					layout : 'fit', // specify layout manager for items
					items : [{
								xtype : 'box',
								autoEl : {
									tag : 'div',
									html : toolbar
								}

							}]
				}, {
					region : 'west',
					width : 0,
					minSize : 0,
					maxSize : 10,
					border : false,
					margins : '0 0 0 0',
					items : []
				}, {
					xtype : 'portal',
					region : 'center',
					margins : '0 0 0 0',
					border : false,
					items : [{
								columnWidth : .35,
								style : 'padding:10px 0 0 10px',
								items : [{
											title : '<font class="oaFont">会议纪要</font>',
											id : 'hyjy',
											html : hyjyHtml
										}, {
											title : '<font class="oaFont">通知公告</font>',
											id : 'tzgg',
											html : tzggHtml
										}]
							}, {
								columnWidth : .65,
								style : 'padding:10px 0 0 10px',
								items : [{
											title : '<font class="oaFont">待办事宜</font>',
											layout : 'fit',
											items : new SampleGrid([0, 2, 3])
										}]
							}]
				}]
	});

	initInfoArea('root_hyjy', getHyjy);
	initInfoArea('root_tzgg', getTzgg);
});